{
    //字符unicode
    console.log('a', '\u0061')
    //>#FFFFFF
    console.log('s', `\u20bb7`)

    console.log('s', `\u{20bb7}`)

    let s = '𠮷'

}

{
    let s = '𠮷'
    //每两个字节
    console.log('length:', s.length)
    console.log('0', s.charAt(0));
    console.log('1', s.charAt(1));
    //es5
    console.log('at0', s.charCodeAt(0));
    console.log('at1', s.charCodeAt(1));
    //es6
    let s1 = '𠮷a'
    console.log('length', s1.length)
    console.log('code0', s1.codePointAt(0));
    //转成16进制
    console.log('code0', s1.codePointAt(0).toString(16));
    console.log('code1', s1.codePointAt(1).toString(16));
    console.log('code2', s1.codePointAt(2));
}


{
    //乱码 es5
    console.log(String.fromCharCode('0x20bb7'))
    //𠮷 es6
    console.log(String.fromCodePoint('0x20bb7'))
}

{
    //es5
    let str = '\u{20bb7}abc'
    for (let i = 0; i < str.length; i++) {
        console.log('es5:', str[i])
    }

    //es6
    for (let code of str) {
        console.log('es6:', code)
    }
}
{
    let str = "string"
    console.log('includes:', str.includes('r'))

    console.log('start:', str.startsWith('str'))

    console.log('end:', str.endsWith('ing'))
}

{
    let str = 'abc'
    //字符串复制
    console.log(str.repeat(2));
}

{
    let name = 'list'
    let info = 'hello world'
    let a = `i am ${name},${info}`
    console.log(a)
}

{
    //前面补零1 变01
    console.log('1'.padStart(2, '0'));
    //后面补零1 变10
    console.log('1'.padEnd(2, '0'));
}

{
    //标签模版
    let user = {
        name: 'list',
        info: 'huangliusong'
    }
    abc`i am ${user.name},${user.info}`
    console.log(abc`i am ${user.name},${user.info}`)
    function abc(s, v1, v2) {
        console.log(s, v1, v2)
        return s + v1 + v2
    }
}

{
    console.log(String.raw`Hi\n${1 + 2}`)
    console.log(`Hi\n${1 + 2}`)
}